package xyz.xpman.prisonerfitness.util;


import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Build;
import android.view.View;
import android.view.WindowManager;

import androidx.annotation.RequiresApi;

import org.jetbrains.annotations.NotNull;

@SuppressWarnings("unused")
public class ActivityUtil {

    private ActivityUtil() {}


    public static void fullScreen(@NotNull Activity context) {
        context.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }


    /**
     * 隐藏状态栏
     */
    @RequiresApi(api = Build.VERSION_CODES.P)
    public static void hideStatusBar(@NotNull Activity context){
        WindowManager.LayoutParams lp = context.getWindow().getAttributes();
        lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
        context.getWindow().setAttributes(lp);
    }



//    public static void hideTitleBar(@NotNull Activity context){
//        context.requestWindowFeature(Window.FEATURE_NO_TITLE);
//    }

    /**
     * 隐藏虚拟按键，并且全屏
     */
    @SuppressLint("ObsoleteSdkInt")
    public static void hideBottomUIMenu(@NotNull Activity context) {
        context.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);

        if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) {
            View v = context.getWindow().getDecorView();
            v.setSystemUiVisibility(View.GONE);
        } else if (Build.VERSION.SDK_INT >= 19) {
            View decorView = context.getWindow().getDecorView();
            int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY ;
            decorView.setSystemUiVisibility(uiOptions);
        }
    }



}
